#include "stdafx.h"
#include "HandleGuard.h"

namespace GenericFilter
{
    namespace Process
    {

        HandleGuard::HandleGuard(HANDLE handle) : handle(handle)
        {

        }

        HandleGuard::~HandleGuard()
        {
            if (handle != INVALID_HANDLE_VALUE)
                ::CloseHandle(handle);
            handle = INVALID_HANDLE_VALUE;
        }

        HANDLE HandleGuard::get()
        {
            return handle;
        }

        HANDLE HandleGuard::release()
        {
            handle = INVALID_HANDLE_VALUE;
        }

    }
}